
var userName='wangying69';
userName="chengcheng1";
userName=localStorage['MU30-lOGIN-USRNAME'];
/**
 * 申请人基本信息获取
 */
//http://mumobiletest30.ceair.com:8011/11206260/public/;
var getApplyInfo=h_yddfUrl+"DFECIF/getApplyInfo?userName="; 
function getApplyInfoFuc(callback)
{
    Loading(0);
    $.ajax({ 
             type: "GET",
             url: getApplyInfo+userName,
             data:'',
             dataType: "json",
             success: function(json){
                  console.log(JSON.stringify(json));
                  Loading(-1);
                  callback(json);
             },
             error: function(erro){
                // alert(JSON.stringify(erro));
             }
         });
}

/**
 * 获取工作流第一个审批节点上的基本信息
 */
var getSecondNodeInfo=h_yddfUrl+"DFECIF/getSecondNodeInfo?processKey=leaveApply&operUserName="; 
function getSecondNodeInfoFuc(callback)
{
   var operUserName="wangying69";
    Loading(0);
    $.ajax({ 
             type: "GET",
             url: getSecondNodeInfo+userName,
             data:'',
             dataType: "json",
             success: function(json){
                  // console.log(JSON.stringify(json));
                  Loading(-1);
                  callback(json);
             },
             error: function(erro){
                // alert(JSON.stringify(erro));
             }
         });
}

/**
 * 获取用户待办接口
 */
var queryUserDutys=h_yddfUrl+"DFECIF/queryUserDutys?userName="; 
function queryUserDutysFuc(callback)
{
    console.log(queryUserDutys+userName);
    Loading(0);
    $.ajax({ 
             type: "GET",
             url: queryUserDutys+userName,
             data:'',
             dataType: "json",
             success: function(json){
                  // console.log(JSON.stringify(json));
                  Loading(-1);
                  callback(json);
             },
             error: function(erro){
                // alert(JSON.stringify(erro));
             }
         });
}

/**
 * 申请人基本信息获取
 */
var getApplyInfoByTaskId=h_yddfUrl+"DFECIF/getApplyInfoByTaskId?taskId="; 
function getApplyInfoByTaskIdFuc(callback)
{
    // var taskId='520062';  //510042
    var taskId=localStorage.getItem("applyTaskid");
    Loading(0);
    $.ajax({ 
             type: "GET",
             url: getApplyInfoByTaskId+taskId,
             data:'',
             dataType: "json",
             success: function(json){
                  // console.log(JSON.stringify(json));
                  Loading(-1);
                  callback(json);
             },
             error: function(erro){
                // alert(JSON.stringify(erro));
             }
         });
}
/**
 * 获取审批历史记录及下一步处理步骤等信息
 */
var getCheckInfoByTaskId=h_yddfUrl+"DFECIF/getCheckInfoByTaskId?processKey=leaveApply&taskId="; 
function getCheckInfoByTaskIdFuc(callback)
{
    // var taskId='520062';
    var taskId=localStorage.getItem("applyTaskid");
    console.log(getCheckInfoByTaskId+taskId)
    Loading(0);
    $.ajax({ 
             type: "GET",
             url: getCheckInfoByTaskId+taskId,
             data:'',
             dataType: "json",
             success: function(json){
                  // console.log("getCheckInfoByTaskIdFuc: "+JSON.stringify(json));
                  Loading(-1);
                  callback(json);
             },
             error: function(erro){
                // alert(JSON.stringify(erro));
             }
         });
}
/**
 * 获取审批节点上的审批方式和审批人信息
 */
var getNodeInfoByNodeName=h_yddfUrl+"DFECIF/getNodeInfoByNodeName?processKey=leaveApply&nodeName="; 
function getNodeInfoByNodeNameFuc(callback)
{
    var nodeName='待部领导审批';
    Loading(0);
    $.ajax({ 
             type: "GET",
             url: getNodeInfoByNodeName+nodeName,
             data:'',
             dataType: "json",
             success: function(json){
                  // console.log(JSON.stringify(json));
                  Loading(-1);
                  callback(json);
             },
             error: function(erro){
                // alert(JSON.stringify(erro));
             }
         });
}
/**
 * 审批流程 
 */
var getDoProcess=h_yddfUrl+"DFECIF/doProcess?"; 
function getDoProcessFuc(doProcessStr)
{
    Loading(0);
    $.ajax({ 
             type: "GET",
             url: getDoProcess+doProcessStr,
             data:'',
             dataType: "json",
             success: function(json){
                  console.log(JSON.stringify(json));
                  Loading(-1);
                  // callback(json);
                 reLoadListPage();
             },
             error: function(erro){
                // alert(JSON.stringify(erro));
             }
         });
}
/**
 * 申请结束后，申请人查看审批结果接口 :申请人基本信息获取
 */
var getApplyDetailInfo=h_yddfUrl+"DFECIF/getApplyDetailInfo?executionId="; 
function getApplyDetailInfoFuc(callback)
{
    var executionId="communication.40";
    Loading(0);
    $.ajax({ 
             type: "GET",
             url: getApplyDetailInfo+executionId,
             data:'',
             dataType: "json",
             success: function(json){
                  // console.log(JSON.stringify(json));
                  Loading(-1);
                  callback(json);
             },
             error: function(erro){
                // alert(JSON.stringify(erro));
             }
         });
}
/**
 * 历史审批记录获取
 */
var getOperateLogsByExecutionId=h_yddfUrl+"DFECIF/getOperateLogsByExecutionId?executionId="; 
function getOperateLogsByExecutionIdFuc(callback)
{
    var executionId="communication.40";
    Loading(0);
    $.ajax({ 
             type: "GET",
             url: getOperateLogsByExecutionId+executionId,
             data:'',
             dataType: "json",
             success: function(json){
                  // console.log(JSON.stringify(json));
                  Loading(-1);
                  callback(json);
             },
             error: function(erro){
                // alert(JSON.stringify(erro));
             }
         });
}
/**
 * 提交
 */
var doSubmit=h_yddfUrl+"DFECIF/doSubmit"; 
function doSubmitFuc(jsonstr)
{
    // jsonstr=JSON.stringify(jsonstr);
    Loading(0);
    $.ajax({ 
             type: "POST",
             url: doSubmit,
             data:jsonstr,
             dataType: "json",
             success: function(json){
                  // console.log(JSON.stringify(json));
                  Loading(-1);
                  appcan.window.alert({
                    title:'提示',
                    content:'提交成功！',
                    buttons:'确定'
                 });
                 reLoadListPage();
             },
             error: function(erro){
                alert(JSON.stringify(erro));
             }
         });
} 
function apply_submitData(){
   var jsonstr1={
        "accessory": "",
        "applyDate": null,
        "applyId": 0,
        "applyReason":"abc",
        "applyType": "TX",
        "cnName": "沈胡影123",
        "companyCode": "",
        "createTime": null,
        "creatorId": 0,
        "creatorName": "",
        "deptName": "外航服务中心123",
        "empType": "",
        "endDate": "2016-11-20",
        "endTime":"17:00",
        "enterCompanyDate": null,
        "id": 0,
        "modifyId": 0,
        "modifyName": "",
        "modifyTime": null,
        "nextDealers": "shenhuying",
        "startDate": "2016-12-18",
        "startTime":  "17:00",
        "startWorkDate": null,
        "status": "",
        "totalDay": "2",
        "totalTime": "16",
        "userName": "shenhuying"
    }
    jsonstr1=JSON.stringify(jsonstr1);
    // jsonstr1.replace(/[\\]/g,"");
    // console.log(jsonstr1)
    var jsonstr={"jsonstr":jsonstr1};
    doSubmitFuc(jsonstr);
}
function apply_checkNextStep(){
   alert('checkNextStep');
}
function getTimeStr(d)
{
    var vYear = d.getFullYear();
    var m=d.getMonth() + 1;
    var vMon =m>=10?m: "0"+m;
    var day=d.getDate();
    var vDay =day>=10?day: "0"+day;
    // var vH=d.getHours();
    // vH=vH>=10?vH: "0"+vH;
    // var vM=d.getMinutes();
    // vM=vM>=10?vM: "0"+vM;
    
    return vYear+"-"+vMon+"-"+vDay;
}
/*
 * 获取详细时间
 */
function getTimeStrDetail(d)
{
    var vYear = d.getFullYear();
    var m=d.getMonth() + 1;
    var vMon =m>=10?m: "0"+m;
    var day=d.getDate();
    var vDay =day>=10?day: "0"+day;
    var vH=d.getHours();
    vH=vH>=10?vH: "0"+vH;
    var vM=d.getMinutes();
    vM=vM>=10?vM: "0"+vM;
    var vS=d.getSeconds();
    vS=vS>=10?vS: "0"+vS;
    return vYear+"-"+vMon+"-"+vDay+" "+vH+":"+vM+":"+vS;
}
/**
 * 获取时间：年-月-日
 */
function getDates()
{
    var d = new Date();
    var vYear = d.getFullYear();
    var m=d.getMonth() + 1;
    var vMon =m>=10?m: "0"+m;
    var day=d.getDate();
    var vDay =day>=10?day: "0"+day;
    
    // DATE=vYear+"-"+vMon+"-"+vDay;
    return vYear+"-"+vMon+"-"+vDay;
}
/**
 * 请假类别字符转换
 */
function applyType(type)
{
   var str='';
    switch(type)
    {
        case "NJ":
            str="年假";
        break;
        case "TX":
            str="调休";
        break;
        case "SJ":
            str="事假";
        break;
        case "BJ":
            str="病假";
        break;
        default:
            str=type;
        break;
    }
    return str;
}
/**
 *提交请假单、请假单处理成功后重新加载list页面 
 */
function reLoadListPage()
{
    // alert("reLoadListPage");
    appcan.window.open({
        name:'applyList',
        dataType:0,
        data:'applyList.html?'+Math.random()
     });
    ueppscript("applyList", "content", "init()");
}
